module lag
    implicit none
    real,parameter :: x0(4)=(/1.05, 1.10, 1.15, 1.20/),&
        y0(4)=(/2.12, 2.20, 2.17, 2.32/)
contains
    real function f(x)
        implicit none
        real :: x,x1(4,4),x2(4,4),yt(4)
        integer :: i,j
        forall(i=1:4,j=1:4,i/=j)
            x1(i,j)=x-x0(j)
            x2(i,j)=x0(i)-x0(j)
        end forall
        forall(i=1:4,j=1:4,i==j)
            x1(i,j)=1.0
            x2(i,j)=1.0
        end forall
        forall(i=1:4)yt(i)=product(x1(i,:)/x2(i,:))
        f=sum(yt*y0)
    end function
end module
program main
    use lag
    implicit none
    real,parameter :: xlist(6) = (/1.0,1.2,1.4,1.6,1.8,2.0/)
    integer :: i
!$OMP PARALLEL DO DEFAULT(PRIVATE)
    do i = 1,6
        write(*,"(f6.2,3x,f8.4)")xlist(i),f(xlist(i))
    end do
!$OMP END PARALLEL DO
end program
